// ------------------------------------
const fs = require('fs');



// 如果persons.json中含有对应的用户名和密码则提示登录成功，否则提示用户名和密码错误
let user = { username:"xm1",password:"12324" }
let pathfile="C:/Users/IBM/Desktop/软件学院0906/day07nodejs/代码/昨天作业/data/persons.json"
let persons=JSON.parse(fs.readFileSync(pathfile,"utf-8"))



// 作比较
let index=persons.findIndex(item=>{

    return user.username==item.username&& user.password==item.password
})




if(index==-1){
   console.log("用户名和密码错误"); 
}else{
    console.log("登录成功");
}
